
var bpath = '';
var bpath_flag = 'ck';
var action = 'videoinfoAction!getUrl.action?id=[$pat]';
var js_path = "resources/framework/plug/player/video/ckplayer/ckplayer";
$(document).ready(function() { 
	bpath = $("#path").val();
	//http协议下的：flv,f4v,mp4 
	action = bpath+action;
	
	action = bpath+"test/resources/files/dwh.flv";
	
	$(".video").each(function(){
		getVideo(this.id);
	});
});  

function getVideo(elementId,type){
	var id  =  getIdFromElementId("video",elementId);
	loadVideo(action,id,"a"+id,"ckplayer_a"+id,type);
}
/**
 * 得到一个元素的id
 * @param beforeName
 * @param elementId
 * @returns
 */
function getIdFromElementId(beforeName,elementId)
{
	var start_index = beforeName.length;
	var end_index = elementId.length;
	return elementId.substring(start_index, end_index); // 获取子字符串。
}
function getFlashvars(action,url_id,type){
	var flashvars={};
	if(type==1){
		flashvars={
				//f:url 
				 f:action
				,s:1
				,a:url_id
				,c:0
				,p:0//默认不播放，1是默认播放
				,e:0//默认播放完后暂停，1是循环播放
				,m:0//是默认打开页面就加载视频，1是打开页面但不加载视频
				,i:''//在默认暂停或默认不加载视频的情况下显示一张缩略图 
				,d:''
				,u:''
		 };
	}else{
		flashvars={
				f:action 
				,s:0
				,c:0
				,p:0//默认不播放，1是默认播放
				,e:0//默认播放完后暂停，1是循环播放
				,m:0//是默认打开页面就加载视频，1是打开页面但不加载视频
				,i:''//在默认暂停或默认不加载视频的情况下显示一张缩略图 
				,d:''
				,u:''
				};
	}
	
	return flashvars;
}
function loadVideo(action,url_id,show_id,show_name,type){
	var flashvars=getFlashvars(action,url_id,type);
	var params={bgcolor:'#000',allowFullScreen:true,allowScriptAccess:'always'};
	var attributes={id:show_name,name:show_name};
	swfobject.embedSWF(js_path+'/ckplayer.swf', show_id, '600', '400', '10.0.0',js_path+'/expressInstall.swf', flashvars, params, attributes); 
 
	var video={url:'video/mp4'}; 
	var support=['iPad','iPhone','ios','android+false','msie10+false'];
	CKobject.embedHTML5('video',show_name,600,400,video,flashvars,support);
	
} 
